/* 
 * Copyright (c) 2008 Knightsoft
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package com.knightsoft.util;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

/**
 * Tool for running Swing demos from the
 * console, both applets and JFrames.
 * Example : SwingConsole.run(new JFrame(),300,500);
 * 
 * @version V1.1 Nov 10, 2008
 * @author Michael
 */
public class SwingConsole {
	public static void run(final JFrame f, final int width, final int height) {
		SwingUtilities.invokeLater(new Runnable() {
			
			public void run() {
				if (f.getTitle().equals(""))
					f.setTitle(f.getClass().getSimpleName());
				
				f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				f.setSize(width, height);
				f.setVisible(true);
			}
		});
	}
}
